In-class Excercise 8: Hedonic Pricing Model

Show the code
pacman::p_load(olsrr,ggstatsplot,sf,tidyverse,ggpubr,spdep,GWmodel,tmap,gtsummary)

Import data

The longitude and latitude in condo_resale dataset is in decimal degree, highly likely to adopt WGS84 coordinate system. When we convert condo_resale into sf, we first indicate that it is using coordinate system WGS84 (EPSG:4326), then project into Singapore coordinate system SVY21 (EPSG:3414).

Show the code
mpsz <- st_read(dsn = "../../data/geospatial",
                layer = "MP14_SUBZONE_WEB_PL") %>% 
  st_transform(3414)
Reading layer `MP14_SUBZONE_WEB_PL' from data source 
  `/Users/tangtang/Desktop/IS415 Geospatial Analytics and Applications/practice/is415gaa/data/geospatial' 
  using driver `ESRI Shapefile'
Simple feature collection with 323 features and 15 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 2667.538 ymin: 15748.72 xmax: 56396.44 ymax: 50256.33
Projected CRS: SVY21
Show the code
condo_resale <- read_csv("../../data/aspatial/Condo_resale_2015.csv")
Rows: 1436 Columns: 23
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
dbl (23): LATITUDE, LONGITUDE, POSTCODE, SELLING_PRICE, AREA_SQM, AGE, PROX_...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Show the code
condo_resale.sf <- st_as_sf(condo_resale,
                            coords = c("LONGITUDE","LATITUDE"),
                            crs = 4326) %>% 
  st_transform(3414)

Exploratory Data Analysis

Visualising relationships between variables

This function ggcorrmat() from ggstatsmodel package provides information than the regular corrmat() used in Hands-on Excercise 8.

This quick plot function will identify both significant and insignificant variables.

Show the code
ggcorrmat(condo_resale[,5:23])

Hedonic Pricing Model - Multivariate Linear regression

When porting into Shiny app, the independent variables are to be joined with + instead of ,.

Show the code
condo.mlr <- lm(formula = SELLING_PRICE ~ AREA_SQM + AGE    + 
                  PROX_CBD + PROX_CHILDCARE + PROX_ELDERLYCARE +
                  PROX_URA_GROWTH_AREA + PROX_HAWKER_MARKET + PROX_KINDERGARTEN + 
                  PROX_MRT  + PROX_PARK + PROX_PRIMARY_SCH + 
                  PROX_TOP_PRIMARY_SCH + PROX_SHOPPING_MALL + PROX_SUPERMARKET + 
                  PROX_BUS_STOP + NO_Of_UNITS + FAMILY_FRIENDLY + FREEHOLD, 
                data=condo_resale.sf)
summary(condo.mlr)

Call:
lm(formula = SELLING_PRICE ~ AREA_SQM + AGE + PROX_CBD + PROX_CHILDCARE + 
    PROX_ELDERLYCARE + PROX_URA_GROWTH_AREA + PROX_HAWKER_MARKET + 
    PROX_KINDERGARTEN + PROX_MRT + PROX_PARK + PROX_PRIMARY_SCH + 
    PROX_TOP_PRIMARY_SCH + PROX_SHOPPING_MALL + PROX_SUPERMARKET + 
    PROX_BUS_STOP + NO_Of_UNITS + FAMILY_FRIENDLY + FREEHOLD, 
    data = condo_resale.sf)

Residuals:
     Min       1Q   Median       3Q      Max 
-3475964  -293923   -23069   241043 12260381 

Coefficients:
                       Estimate Std. Error t value Pr(>|t|)    
(Intercept)           481728.40  121441.01   3.967 7.65e-05 ***
AREA_SQM               12708.32     369.59  34.385  < 2e-16 ***
AGE                   -24440.82    2763.16  -8.845  < 2e-16 ***
PROX_CBD              -78669.78    6768.97 -11.622  < 2e-16 ***
PROX_CHILDCARE       -351617.91  109467.25  -3.212  0.00135 ** 
PROX_ELDERLYCARE      171029.42   42110.51   4.061 5.14e-05 ***
PROX_URA_GROWTH_AREA   38474.53   12523.57   3.072  0.00217 ** 
PROX_HAWKER_MARKET     23746.10   29299.76   0.810  0.41782    
PROX_KINDERGARTEN     147468.99   82668.87   1.784  0.07466 .  
PROX_MRT             -314599.68   57947.44  -5.429 6.66e-08 ***
PROX_PARK             563280.50   66551.68   8.464  < 2e-16 ***
PROX_PRIMARY_SCH      180186.08   65237.95   2.762  0.00582 ** 
PROX_TOP_PRIMARY_SCH    2280.04   20410.43   0.112  0.91107    
PROX_SHOPPING_MALL   -206604.06   42840.60  -4.823 1.57e-06 ***
PROX_SUPERMARKET      -44991.80   77082.64  -0.584  0.55953    
PROX_BUS_STOP         683121.35  138353.28   4.938 8.85e-07 ***
NO_Of_UNITS             -231.18      89.03  -2.597  0.00951 ** 
FAMILY_FRIENDLY       140340.77   47020.55   2.985  0.00289 ** 
FREEHOLD              359913.01   49220.22   7.312 4.38e-13 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 755800 on 1417 degrees of freedom
Multiple R-squared:  0.6518,    Adjusted R-squared:  0.6474 
F-statistic: 147.4 on 18 and 1417 DF,  p-value: < 2.2e-16

The function tbl_regression() from gtsummary would create a tidy HTML summary table. In this excercise, we are including more model statistics into

Show the code
# tbl_regression(condo.mlr,
#                intercept = TRUE) %>% 
#   add_glance_source_note(
#     label = list(sigma ~ )
#   )

Visualising model parameter

Use function ggcoefstats() from ggstatsmodel

This includes beta, t statistics and p-value for each variable, while indicating confidence interval with mean in form of line with dot.

When line/confidence interval is shorter, we are more confident (?)

Show the code
mlr.p <- ggcoefstats(condo.mlr,
                     sort = "ascending")
Number of labels is greater than default palette color count.
• Select another color `palette` (and/or `package`).
Show the code
mlr.p

Fixed bandwidth

Show the code
condo_resale.sp <- as_Spatial(condo_resale.sf)
Show the code
bw.fixed <- bw.gwr(formula = SELLING_PRICE ~ AREA_SQM + AGE    + 
                  PROX_CBD + PROX_CHILDCARE + PROX_ELDERLYCARE +
                  PROX_URA_GROWTH_AREA + PROX_HAWKER_MARKET + PROX_KINDERGARTEN + 
                  PROX_MRT  + PROX_PARK + PROX_PRIMARY_SCH + 
                  PROX_TOP_PRIMARY_SCH + PROX_SHOPPING_MALL + PROX_SUPERMARKET + 
                  PROX_BUS_STOP + NO_Of_UNITS + FAMILY_FRIENDLY + FREEHOLD, 
                data=condo_resale.sp,
                approach = "CV",
                kernel = "gaussian",
                adaptive = FALSE,
                longlat = FALSE)
Fixed bandwidth: 17660.96 CV score: 8.235467e+14 
Fixed bandwidth: 10917.26 CV score: 7.902384e+14 
Fixed bandwidth: 6749.419 CV score: 7.152539e+14 
Fixed bandwidth: 4173.553 CV score: 6.182116e+14 
Fixed bandwidth: 2581.58 CV score: 5.257275e+14 
Fixed bandwidth: 1597.687 CV score: 4.748442e+14 
Fixed bandwidth: 989.6077 CV score: 5.095011e+14 
Fixed bandwidth: 1973.501 CV score: 4.85724e+14 
Fixed bandwidth: 1365.421 CV score: 4.766341e+14 
Fixed bandwidth: 1741.235 CV score: 4.772231e+14 
Fixed bandwidth: 1508.969 CV score: 4.745788e+14 
Fixed bandwidth: 1454.139 CV score: 4.749631e+14 
Fixed bandwidth: 1542.857 CV score: 4.7456e+14 
Fixed bandwidth: 1563.8 CV score: 4.746245e+14 
Fixed bandwidth: 1529.913 CV score: 4.745487e+14 
Fixed bandwidth: 1521.913 CV score: 4.745531e+14 
Fixed bandwidth: 1534.857 CV score: 4.745504e+14 
Fixed bandwidth: 1526.857 CV score: 4.745494e+14 
Fixed bandwidth: 1531.801 CV score: 4.74549e+14 
Fixed bandwidth: 1528.746 CV score: 4.745488e+14 
Fixed bandwidth: 1530.634 CV score: 4.745488e+14 
Fixed bandwidth: 1529.467 CV score: 4.745487e+14 
Fixed bandwidth: 1530.188 CV score: 4.745487e+14 
Fixed bandwidth: 1529.743 CV score: 4.745487e+14 
Fixed bandwidth: 1530.018 CV score: 4.745487e+14 
Fixed bandwidth: 1529.848 CV score: 4.745487e+14 
Fixed bandwidth: 1529.808 CV score: 4.745487e+14 
Fixed bandwidth: 1529.873 CV score: 4.745487e+14 
Fixed bandwidth: 1529.888 CV score: 4.745487e+14 
Fixed bandwidth: 1529.863 CV score: 4.745487e+14 
Fixed bandwidth: 1529.879 CV score: 4.745487e+14 
Fixed bandwidth: 1529.869 CV score: 4.745487e+14 
Fixed bandwidth: 1529.875 CV score: 4.745487e+14 
Fixed bandwidth: 1529.871 CV score: 4.745487e+14 
Fixed bandwidth: 1529.87 CV score: 4.745487e+14 
Fixed bandwidth: 1529.87 CV score: 4.745487e+14 
Fixed bandwidth: 1529.871 CV score: 4.745487e+14 
Fixed bandwidth: 1529.87 CV score: 4.745487e+14 
Fixed bandwidth: 1529.871 CV score: 4.745487e+14 
Fixed bandwidth: 1529.87 CV score: 4.745487e+14 
Fixed bandwidth: 1529.87 CV score: 4.745487e+14 
Fixed bandwidth: 1529.87 CV score: 4.745487e+14 

By default 2 models are built, one considering spatial relationship and the other without spatial relationship. Comparing the adjusted R-square (higher → better) to see if having spatial relationship will improve the model.

Compare AICc for performance of individual madels (higher → better).

Show the code
gwr.fixed <- gwr.basic(formula = SELLING_PRICE ~ AREA_SQM + AGE    + 
                  PROX_CBD + PROX_CHILDCARE + PROX_ELDERLYCARE +
                  PROX_URA_GROWTH_AREA + PROX_HAWKER_MARKET + PROX_KINDERGARTEN + 
                  PROX_MRT  + PROX_PARK + PROX_PRIMARY_SCH + 
                  PROX_TOP_PRIMARY_SCH + PROX_SHOPPING_MALL + PROX_SUPERMARKET + 
                  PROX_BUS_STOP + NO_Of_UNITS + FAMILY_FRIENDLY + FREEHOLD,
                  data = condo_resale.sp,
                  bw = bw.fixed,
                  kernel = "gaussian",
                  longlat = FALSE)
gwr.fixed
   ***********************************************************************
   *                       Package   GWmodel                             *
   ***********************************************************************
   Program starts at: 2024-03-11 11:27:57.267851 
   Call:
   gwr.basic(formula = SELLING_PRICE ~ AREA_SQM + AGE + PROX_CBD + 
    PROX_CHILDCARE + PROX_ELDERLYCARE + PROX_URA_GROWTH_AREA + 
    PROX_HAWKER_MARKET + PROX_KINDERGARTEN + PROX_MRT + PROX_PARK + 
    PROX_PRIMARY_SCH + PROX_TOP_PRIMARY_SCH + PROX_SHOPPING_MALL + 
    PROX_SUPERMARKET + PROX_BUS_STOP + NO_Of_UNITS + FAMILY_FRIENDLY + 
    FREEHOLD, data = condo_resale.sp, bw = bw.fixed, kernel = "gaussian", 
    longlat = FALSE)

   Dependent (y) variable:  SELLING_PRICE
   Independent variables:  AREA_SQM AGE PROX_CBD PROX_CHILDCARE PROX_ELDERLYCARE PROX_URA_GROWTH_AREA PROX_HAWKER_MARKET PROX_KINDERGARTEN PROX_MRT PROX_PARK PROX_PRIMARY_SCH PROX_TOP_PRIMARY_SCH PROX_SHOPPING_MALL PROX_SUPERMARKET PROX_BUS_STOP NO_Of_UNITS FAMILY_FRIENDLY FREEHOLD
   Number of data points: 1436
   ***********************************************************************
   *                    Results of Global Regression                     *
   ***********************************************************************

   Call:
    lm(formula = formula, data = data)

   Residuals:
     Min       1Q   Median       3Q      Max 
-3475964  -293923   -23069   241043 12260381 

   Coefficients:
                          Estimate Std. Error t value Pr(>|t|)    
   (Intercept)           481728.40  121441.01   3.967 7.65e-05 ***
   AREA_SQM               12708.32     369.59  34.385  < 2e-16 ***
   AGE                   -24440.82    2763.16  -8.845  < 2e-16 ***
   PROX_CBD              -78669.78    6768.97 -11.622  < 2e-16 ***
   PROX_CHILDCARE       -351617.91  109467.25  -3.212  0.00135 ** 
   PROX_ELDERLYCARE      171029.42   42110.51   4.061 5.14e-05 ***
   PROX_URA_GROWTH_AREA   38474.53   12523.57   3.072  0.00217 ** 
   PROX_HAWKER_MARKET     23746.10   29299.76   0.810  0.41782    
   PROX_KINDERGARTEN     147468.99   82668.87   1.784  0.07466 .  
   PROX_MRT             -314599.68   57947.44  -5.429 6.66e-08 ***
   PROX_PARK             563280.50   66551.68   8.464  < 2e-16 ***
   PROX_PRIMARY_SCH      180186.08   65237.95   2.762  0.00582 ** 
   PROX_TOP_PRIMARY_SCH    2280.04   20410.43   0.112  0.91107    
   PROX_SHOPPING_MALL   -206604.06   42840.60  -4.823 1.57e-06 ***
   PROX_SUPERMARKET      -44991.80   77082.64  -0.584  0.55953    
   PROX_BUS_STOP         683121.35  138353.28   4.938 8.85e-07 ***
   NO_Of_UNITS             -231.18      89.03  -2.597  0.00951 ** 
   FAMILY_FRIENDLY       140340.77   47020.55   2.985  0.00289 ** 
   FREEHOLD              359913.01   49220.22   7.312 4.38e-13 ***

   ---Significance stars
   Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
   Residual standard error: 755800 on 1417 degrees of freedom
   Multiple R-squared: 0.6518
   Adjusted R-squared: 0.6474 
   F-statistic: 147.4 on 18 and 1417 DF,  p-value: < 2.2e-16 
   ***Extra Diagnostic information
   Residual sum of squares: 8.094732e+14
   Sigma(hat): 751322.9
   AIC:  42970.18
   AICc:  42970.77
   BIC:  41784.96
   ***********************************************************************
   *          Results of Geographically Weighted Regression              *
   ***********************************************************************

   *********************Model calibration information*********************
   Kernel function: gaussian 
   Fixed bandwidth: 1529.87 
   Regression points: the same locations as observations are used.
   Distance metric: Euclidean distance metric is used.

   ****************Summary of GWR coefficient estimates:******************
                               Min.     1st Qu.      Median     3rd Qu.
   Intercept            -1.7294e+06  5.0686e+05  1.2459e+06  2.0286e+06
   AREA_SQM              2.7257e+03  5.4383e+03  7.8679e+03  1.2293e+04
   AGE                  -8.0810e+04 -2.5075e+04 -1.2338e+04 -5.6014e+03
   PROX_CBD             -1.4408e+06 -2.7205e+05 -1.7043e+05 -6.6519e+04
   PROX_CHILDCARE       -3.2769e+06 -2.2120e+05 -5.9600e+04  1.0788e+05
   PROX_ELDERLYCARE     -1.6966e+06 -3.5677e+04  8.9834e+04  2.0528e+05
   PROX_URA_GROWTH_AREA -7.0723e+05  9.2127e+03  7.3288e+04  1.8958e+05
   PROX_HAWKER_MARKET   -6.4011e+05 -5.6009e+04  8.2983e+04  4.3080e+05
   PROX_KINDERGARTEN    -1.8548e+06 -3.5646e+05 -1.6452e+05  1.3895e+05
   PROX_MRT             -2.7453e+06 -6.3607e+05 -2.4833e+05 -7.1555e+04
   PROX_PARK            -1.0939e+06 -1.5591e+05  1.0240e+04  3.2499e+05
   PROX_PRIMARY_SCH     -6.2015e+05 -1.8895e+05  1.4868e+03  3.8470e+05
   PROX_TOP_PRIMARY_SCH -7.6447e+05 -1.1127e+05 -1.7162e+04  5.2347e+04
   PROX_SHOPPING_MALL   -9.5378e+05 -1.6176e+05 -2.1287e+04  7.0973e+04
   PROX_SUPERMARKET     -7.2192e+05 -1.1000e+05 -5.9072e+03  1.5699e+05
   PROX_BUS_STOP        -6.2152e+05  4.5824e+04  4.3923e+05  1.5814e+06
   NO_Of_UNITS          -1.6083e+03 -2.9384e+02 -1.0619e+02  5.5081e+00
   FAMILY_FRIENDLY      -1.4636e+06 -4.4834e+04  1.4704e+04  1.7087e+05
   FREEHOLD             -1.4458e+05  8.0776e+04  1.8066e+05  3.4671e+05
                             Max.
   Intercept            9517178.8
   AREA_SQM               19022.4
   AGE                    34460.5
   PROX_CBD              535635.5
   PROX_CHILDCARE       1209089.3
   PROX_ELDERLYCARE     2236812.0
   PROX_URA_GROWTH_AREA 1511628.7
   PROX_HAWKER_MARKET   2415026.9
   PROX_KINDERGARTEN     782179.4
   PROX_MRT              734567.9
   PROX_PARK            1074304.2
   PROX_PRIMARY_SCH     1472504.3
   PROX_TOP_PRIMARY_SCH  883983.8
   PROX_SHOPPING_MALL    595084.1
   PROX_SUPERMARKET     1647456.7
   PROX_BUS_STOP        5131416.8
   NO_Of_UNITS             1483.4
   FAMILY_FRIENDLY      1278255.4
   FREEHOLD              885791.0
   ************************Diagnostic information*************************
   Number of data points: 1436 
   Effective number of parameters (2trace(S) - trace(S'S)): 310.8448 
   Effective degrees of freedom (n-2trace(S) + trace(S'S)): 1125.155 
   AICc (GWR book, Fotheringham, et al. 2002, p. 61, eq 2.33): 42237.55 
   AIC (GWR book, Fotheringham, et al. 2002,GWR p. 96, eq. 4.22): 41869.48 
   BIC (GWR book, Fotheringham, et al. 2002,GWR p. 61, eq. 2.34): 42030.5 
   Residual sum of squares: 3.238745e+14 
   R-square value:  0.860678 
   Adjusted R-square value:  0.8221535 

   ***********************************************************************
   Program stops at: 2024-03-11 11:27:58.505342 

Adaptive

Show the code
bw.adaptive <- bw.gwr(formula = SELLING_PRICE ~ AREA_SQM + AGE  + 
                        PROX_CBD + PROX_CHILDCARE + PROX_ELDERLYCARE    + 
                        PROX_URA_GROWTH_AREA + PROX_MRT + PROX_PARK + 
                        PROX_PRIMARY_SCH + PROX_SHOPPING_MALL   + PROX_BUS_STOP + 
                        NO_Of_UNITS + FAMILY_FRIENDLY + FREEHOLD, 
                      data=condo_resale.sp, 
                      approach="CV", 
                      kernel="gaussian", 
                      adaptive=TRUE, 
                      longlat=FALSE)
Adaptive bandwidth: 895 CV score: 7.952401e+14 
Adaptive bandwidth: 561 CV score: 7.667364e+14 
Adaptive bandwidth: 354 CV score: 6.953454e+14 
Adaptive bandwidth: 226 CV score: 6.15223e+14 
Adaptive bandwidth: 147 CV score: 5.674373e+14 
Adaptive bandwidth: 98 CV score: 5.426745e+14 
Adaptive bandwidth: 68 CV score: 5.168117e+14 
Adaptive bandwidth: 49 CV score: 4.859631e+14 
Adaptive bandwidth: 37 CV score: 4.646518e+14 
Adaptive bandwidth: 30 CV score: 4.422088e+14 
Adaptive bandwidth: 25 CV score: 4.430816e+14 
Adaptive bandwidth: 32 CV score: 4.505602e+14 
Adaptive bandwidth: 27 CV score: 4.462172e+14 
Adaptive bandwidth: 30 CV score: 4.422088e+14 
Show the code
gwr.adaptive <- gwr.basic(formula = SELLING_PRICE ~ AREA_SQM + AGE + 
                            PROX_CBD + PROX_CHILDCARE + PROX_ELDERLYCARE + 
                            PROX_URA_GROWTH_AREA + PROX_MRT + PROX_PARK + 
                            PROX_PRIMARY_SCH + PROX_SHOPPING_MALL + PROX_BUS_STOP + 
                            NO_Of_UNITS + FAMILY_FRIENDLY + FREEHOLD, 
                          data=condo_resale.sp, 
                          bw=bw.adaptive, 
                          kernel = 'gaussian', 
                          adaptive=TRUE, 
                          longlat = FALSE)
gwr.adaptive
   ***********************************************************************
   *                       Package   GWmodel                             *
   ***********************************************************************
   Program starts at: 2024-03-11 11:28:10.045516 
   Call:
   gwr.basic(formula = SELLING_PRICE ~ AREA_SQM + AGE + PROX_CBD + 
    PROX_CHILDCARE + PROX_ELDERLYCARE + PROX_URA_GROWTH_AREA + 
    PROX_MRT + PROX_PARK + PROX_PRIMARY_SCH + PROX_SHOPPING_MALL + 
    PROX_BUS_STOP + NO_Of_UNITS + FAMILY_FRIENDLY + FREEHOLD, 
    data = condo_resale.sp, bw = bw.adaptive, kernel = "gaussian", 
    adaptive = TRUE, longlat = FALSE)

   Dependent (y) variable:  SELLING_PRICE
   Independent variables:  AREA_SQM AGE PROX_CBD PROX_CHILDCARE PROX_ELDERLYCARE PROX_URA_GROWTH_AREA PROX_MRT PROX_PARK PROX_PRIMARY_SCH PROX_SHOPPING_MALL PROX_BUS_STOP NO_Of_UNITS FAMILY_FRIENDLY FREEHOLD
   Number of data points: 1436
   ***********************************************************************
   *                    Results of Global Regression                     *
   ***********************************************************************

   Call:
    lm(formula = formula, data = data)

   Residuals:
     Min       1Q   Median       3Q      Max 
-3470778  -298119   -23481   248917 12234210 

   Coefficients:
                          Estimate Std. Error t value Pr(>|t|)    
   (Intercept)           527633.22  108183.22   4.877 1.20e-06 ***
   AREA_SQM               12777.52     367.48  34.771  < 2e-16 ***
   AGE                   -24687.74    2754.84  -8.962  < 2e-16 ***
   PROX_CBD              -77131.32    5763.12 -13.384  < 2e-16 ***
   PROX_CHILDCARE       -318472.75  107959.51  -2.950 0.003231 ** 
   PROX_ELDERLYCARE      185575.62   39901.86   4.651 3.61e-06 ***
   PROX_URA_GROWTH_AREA   39163.25   11754.83   3.332 0.000885 ***
   PROX_MRT             -294745.11   56916.37  -5.179 2.56e-07 ***
   PROX_PARK             570504.81   65507.03   8.709  < 2e-16 ***
   PROX_PRIMARY_SCH      159856.14   60234.60   2.654 0.008046 ** 
   PROX_SHOPPING_MALL   -220947.25   36561.83  -6.043 1.93e-09 ***
   PROX_BUS_STOP         682482.22  134513.24   5.074 4.42e-07 ***
   NO_Of_UNITS             -245.48      87.95  -2.791 0.005321 ** 
   FAMILY_FRIENDLY       146307.58   46893.02   3.120 0.001845 ** 
   FREEHOLD              350599.81   48506.48   7.228 7.98e-13 ***

   ---Significance stars
   Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
   Residual standard error: 756000 on 1421 degrees of freedom
   Multiple R-squared: 0.6507
   Adjusted R-squared: 0.6472 
   F-statistic: 189.1 on 14 and 1421 DF,  p-value: < 2.2e-16 
   ***Extra Diagnostic information
   Residual sum of squares: 8.120609e+14
   Sigma(hat): 752522.9
   AIC:  42966.76
   AICc:  42967.14
   BIC:  41731.39
   ***********************************************************************
   *          Results of Geographically Weighted Regression              *
   ***********************************************************************

   *********************Model calibration information*********************
   Kernel function: gaussian 
   Adaptive bandwidth: 30 (number of nearest neighbours)
   Regression points: the same locations as observations are used.
   Distance metric: Euclidean distance metric is used.

   ****************Summary of GWR coefficient estimates:******************
                               Min.     1st Qu.      Median     3rd Qu.
   Intercept            -1.3487e+08 -2.4669e+05  7.7928e+05  1.6194e+06
   AREA_SQM              3.3188e+03  5.6285e+03  7.7825e+03  1.2738e+04
   AGE                  -9.6746e+04 -2.9288e+04 -1.4043e+04 -5.6119e+03
   PROX_CBD             -2.5330e+06 -1.6256e+05 -7.7242e+04  2.6624e+03
   PROX_CHILDCARE       -1.2790e+06 -2.0175e+05  8.7158e+03  3.7778e+05
   PROX_ELDERLYCARE     -1.6212e+06 -9.2050e+04  6.1029e+04  2.8184e+05
   PROX_URA_GROWTH_AREA -7.2686e+06 -3.0350e+04  4.5869e+04  2.4613e+05
   PROX_MRT             -4.3781e+07 -6.7282e+05 -2.2115e+05 -7.4593e+04
   PROX_PARK            -2.9020e+06 -1.6782e+05  1.1601e+05  4.6572e+05
   PROX_PRIMARY_SCH     -8.6418e+05 -1.6627e+05 -7.7853e+03  4.3222e+05
   PROX_SHOPPING_MALL   -1.8272e+06 -1.3175e+05 -1.4049e+04  1.3799e+05
   PROX_BUS_STOP        -2.0579e+06 -7.1461e+04  4.1104e+05  1.2071e+06
   NO_Of_UNITS          -2.1993e+03 -2.3685e+02 -3.4699e+01  1.1657e+02
   FAMILY_FRIENDLY      -5.9879e+05 -5.0927e+04  2.6173e+04  2.2481e+05
   FREEHOLD             -1.6340e+05  4.0765e+04  1.9023e+05  3.7960e+05
                            Max.
   Intercept            18758355
   AREA_SQM                23064
   AGE                     13303
   PROX_CBD             11346650
   PROX_CHILDCARE        2892127
   PROX_ELDERLYCARE      2465671
   PROX_URA_GROWTH_AREA  7384059
   PROX_MRT              1186242
   PROX_PARK             2588497
   PROX_PRIMARY_SCH      3381462
   PROX_SHOPPING_MALL   38038564
   PROX_BUS_STOP        12081592
   NO_Of_UNITS              1010
   FAMILY_FRIENDLY       2072414
   FREEHOLD              1813995
   ************************Diagnostic information*************************
   Number of data points: 1436 
   Effective number of parameters (2trace(S) - trace(S'S)): 350.3088 
   Effective degrees of freedom (n-2trace(S) + trace(S'S)): 1085.691 
   AICc (GWR book, Fotheringham, et al. 2002, p. 61, eq 2.33): 41982.22 
   AIC (GWR book, Fotheringham, et al. 2002,GWR p. 96, eq. 4.22): 41546.74 
   BIC (GWR book, Fotheringham, et al. 2002,GWR p. 61, eq. 2.34): 41914.08 
   Residual sum of squares: 2.528227e+14 
   R-square value:  0.8912425 
   Adjusted R-square value:  0.8561185 

   ***********************************************************************
   Program stops at: 2024-03-11 11:28:11.685134 

The SDF table stores all the model results (Standard Error SE, )

Show the code
condo_resale_sdf.adaptive <- st_as_sf(gwr.adaptive$SDF) %>% 
  st_transform(crs = 3414)
condo_resale_sdf.adaptive.svy21 <- st_transform(condo_resale_sdf.adaptive, crs = 3414)

Visualise

Show the code
tmap_options(check.and.fix = TRUE)
tmap_mode("view")
tmap mode set to interactive viewing
Show the code
tm_shape(mpsz)+
  tm_polygons(alpha = 0.1) +
tm_shape(condo_resale_sdf.adaptive) +  
  tm_dots(col = "Local_R2",
          border.col = "gray60",
          border.lwd = 1) +
  tm_view(set.zoom.limits = c(11,14))
Warning: The shape mpsz is invalid (after reprojection). See sf::st_is_valid

The sync parameter will synchronise the maps when one of them moved

Show the code
tmap_options(check.and.fix = TRUE)
tmap_mode("view")
tmap mode set to interactive viewing
Show the code
AREA_SQM_SE <- tm_shape(mpsz)+
  tm_polygons(alpha = 0.1) +
tm_shape(condo_resale_sdf.adaptive) +  
  tm_dots(col = "AREA_SQM_SE",
          border.col = "gray60",
          border.lwd = 1) +
  tm_view(set.zoom.limits = c(11,14))

AREA_SQM_TV <- tm_shape(mpsz)+
  tm_polygons(alpha = 0.1) +
tm_shape(condo_resale_sdf.adaptive) +  
  tm_dots(col = "AREA_SQM_TV",
          border.col = "gray60",
          border.lwd = 1) +
  tm_view(set.zoom.limits = c(11,14))

tmap_arrange(AREA_SQM_SE, AREA_SQM_TV, 
             asp=1, ncol=2,
             sync = TRUE)
Warning: The shape mpsz is invalid (after reprojection). See sf::st_is_valid

Warning: The shape mpsz is invalid (after reprojection). See sf::st_is_valid
Show the code
tmap_mode("plot")
tmap mode set to plotting
Show the code
tm_shape(mpsz[mpsz$REGION_N=="CENTRAL REGION", ])+
  tm_polygons()+
tm_shape(condo_resale_sdf.adaptive) + 
  tm_bubbles(col = "Local_R2",
           size = 0.15,
           border.col = "gray60",
           border.lwd = 1)
Warning: The shape mpsz[mpsz$REGION_N == "CENTRAL REGION", ] is invalid. See
sf::st_is_valid